package com.example.myapplication.navigation

import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.AccountBox
import androidx.navigation.NavGraph.Companion.findStartDestination
import androidx.navigation.NavHostController
import com.example.myapplication.R

/*
interface AppDestination{
    val icon : Int
    val route : String
}

//object开头，是一种对象声明
object Control : AppDestination{
    override val icon: Int
        get() = R.drawable.control_tab_icon
    override val route: String
        get() = "Control"
}

object Smart : AppDestination{
    override val icon: Int
        get() = R.drawable.smart_tab_icon
    override val route: String
        get() = "Smart"
}

object Shop : AppDestination{
    override val icon: Int
        get() = R.drawable.shop_tab_icon
    override val route: String
        get() = "Shop"
}

object Mine : AppDestination{
    override val icon: Int
        get() = R.drawable.mine_tab_icon
    override val route: String
        get() = "Mine"
}

val bottomBarItems = listOf(Control, Smart, Shop, Mine)
*/

//新的定义

object MainRoute{
    const val MainRouteControl = "MainRouteControl"
    const val MainRouteSmart = "MainRouteSmart"
    const val MainRouteShop = "MainRouteShop"
    const val MainRouteMine = "MainRouteMine"
}


//定义所有导航栏的route
object AppRoute {
    const val CONTROL = "Control" //首页-控制页面
    const val SMART = "Smart" //智能页面
    const val SHOP = "Shop" //商城页面
    const val MINE = "Mine" //我的页面


    //控制页面
    const val CONTROL_MAIN = "controlMain" //控制tab-主页面
    const val PLAN_AMOUNT = "PLAN_AMOUNT" //计划金额
    const val ADD_ACCOUNT = "ADD_ACCOUNT" //新增账号


    //智能页面
    const val SMART_MAIN = "smartMain"  //智能tab-主页面


    //商城页面
    const val SHOP_MAIN = "shopMain" //商城tab-主页面


    //我的页面
    const val MINE_MAIN = "mineMain" //我的tab-主页面
    const val ACCOUNT_AND_SECURITY = "Account_And_Security" //账号与安全
    const val APP_SETTING = "App_Setting" //app设置
    const val APP_ABOUTVERSION = "App_AboutVersion" //app关于版本
    const val loginMain = "LoginMain" //退出到登陆页面/登陆页面
}

//定义一个数据类
data class AppDestination(
    val route : String,
    val selectIcon : Int? = null,
    val iconText : Int
)

//定义顶级目的地(底部导航栏)
val TOP_LEVEL_DESTINATIONS = listOf<AppDestination>(
    AppDestination(route = AppRoute.CONTROL, selectIcon = R.drawable.control_tab_icon, iconText = R.string.control),
    AppDestination(route = AppRoute.SMART, selectIcon = R.drawable.smart_tab_icon, iconText = R.string.smart),
    AppDestination(route = AppRoute.SHOP, selectIcon = R.drawable.shop_tab_icon, iconText = R.string.shop),
    AppDestination(route = AppRoute.MINE, selectIcon = R.drawable.mine_tab_icon, iconText = R.string.mine),
)

//Control
val ADD_ACOUNT_DEST = AppDestination(route = AppRoute.ADD_ACCOUNT, selectIcon = R.drawable.login_title_icon, iconText = R.string.smart)
val PALN_MONEY_DEST = AppDestination(route = AppRoute.PLAN_AMOUNT, selectIcon = R.drawable.login_title_icon, iconText = R.string.smart)



/**
 * 导航操作
 */
class AppNavigationActions(private val navController : NavHostController){
    fun navigationTo(destination: AppDestination){
        navController.navigate(destination.route){
            //避免当前使用者选择项目时在返回堆叠上建立一大批目的地
            popUpTo(navController.graph.findStartDestination().id){
                saveState = true
            }
            //避免同一个目的地多个副本
            launchSingleTop = true
        }
    }
}